import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/index/home'
  },
  {
    path: '/index',
    name: 'Index',
    component: () => import('@/views/yimi-index.vue'),
    children: [
      {
        path: 'home',
        name: 'Home',
        component: () => import('@/views/yimi-home.vue')
      },
      {
        path: 'category',
        name: 'Category',
        component: () => import('@/views/yimi-category.vue')
      },
      {
        path: 'collection',
        name: 'Collection',
        component: () => import('@/views/yimi-collection.vue')
      },
    ]
  },


  {
    path: '/search',
    name: 'Search',
    component: () => import('@/views/yimi-search.vue'),

  },
  {
    path: '/list',
    name: 'Product',
    component: () => import('@/pages/page-result.vue')
  },
  {
    path: '/categorylist',
    name: 'CategoryList',
    component: () => import('@/pages/page-catelist.vue')
  }
  ,
  {
    path: '/detail',
    name: 'Detail',
    component: () => import('@/views/yimi-detail.vue')
  },

  {
    path: '/setup',
    name: 'Setup',
    component: () => import('@/views/yimi-setUp.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/yimi-login.vue')
  }

]

const router = new VueRouter({
  routes
});

router.beforeEach((to, from, next) => {
  // console.log(to);
  // console.log(from)
  next();
})

export default router
